package View;




import javax.swing.JPanel;
import javax.swing.JTabbedPane;



import Model.IUpdatable;

import Presenter.PlayerInfoPresenter;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class MainPageView extends JPanel {

	/**
	 * Panel for the main view
	 */
	
	private final JTabbedPane tabbedPane;
	
	/**
	 * Constrcutor
	 */
	public MainPageView() {
		
		tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
		add(tabbedPane);
		
		final Universe panel = Universe.getInstance();

		//add tip text
		tabbedPane.addTab("Universe Map", null, panel, "Universe.");

		tabbedPane.addTab("Player Info", null, new PlayerInfoPresenter()
		    .getView(), "All of your player's information.");
		
		tabbedPane.addTab("MarketPlace", null, new MarketPlaceView(), 
		        "Peddle goods here.");
		tabbedPane.addTab("Ship Upgrades", null, new SpaceshipInfoView(), 
		        "Movin' on up.");
		tabbedPane.addTab("Save/Load", null, new SaveLoadView(), 
		        "Go sleep, and come back later.");
		
		tabbedPane.setSelectedIndex(1);
		
		tabbedPane.addChangeListener(new ChangeListener()
	    {
			@Override
			public void stateChanged(ChangeEvent arg0) {
				if(tabbedPane != null){
					((IUpdatable) tabbedPane.getSelectedComponent()).update();
				}
				
			}
	    });
	}
}
